package org.arain.baseii.system.department;

import javax.servlet.http.HttpServletRequest;

import org.arain.baseii.utils.AppUtils;
import org.arain.baseii.utils.ArainResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("system/department")
public class DepartmentController {
	@Autowired
	private DepartmentService departmentService;
	
	@RequestMapping("list_01")
	public String list_01(DepartmentDto departmentDto,Model model,HttpServletRequest request) {
		ArainResult result = departmentService.load_01(departmentDto, request);
		model.addAttribute("sysGroup", result.getData());
		model.addAttribute("orgid", AppUtils.getOrgId());
		model.addAttribute("sysDepartment", "");
		return "system/department/list_01";
	}
	
	
	@RequestMapping("save.do")
	@ResponseBody
	public ArainResult save_01(DepartmentDto departmentDto,HttpServletRequest request) {
		return departmentService.save_01(departmentDto,request);
	}
	
	@RequestMapping(value="load_edit_grid")
	@ResponseBody
	public String load_edit_grid(Long orgid) {
		return departmentService.load_orgid(orgid);
	}
	
	@RequestMapping(value="load_type")
	@ResponseBody
	public String load_type() {
		return departmentService.load_type();
	}
	
	@RequestMapping(value="load_01")
	@ResponseBody
	public String load_01() {
		return departmentService.load_enabled();
	}
}
